<?php

namespace App\Models\Guanyuan;

use App\Models\BaseModel;
use App\Models\Traits\KfSoftDeletes;
use App\Models\Traits\KfUid;
use Illuminate\Database\Eloquent\Relations\HasOne;

class GuanyuanAccountBindModel extends BaseModel
{
    use KfUid;
    use KfSoftDeletes;

    protected $table = "guanyuan_account_bind";

    protected $fillable = [
        'id',
        'fsUserId',
        'guanyuanAccountId',
        'isDeleted',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
    ];

    public static function insertData(array $data): bool
    {
        return self::query()->insert($data);
    }


    public static function getCount(int $guanyuanAccountId): int
    {
        return self::query()->where('guanyuanAccountId', $guanyuanAccountId)->count();
    }

    public function guanyuanAccountRel(): HasOne
    {
        return $this->hasOne(GuanyuanAccountModel::class, 'id', 'guanyuanAccountId');
    }
}
